package org.openspml.providers.one_c;

import java.util.ResourceBundle;

import org.openspml.providers.one_c.api.connection.COMConnector;
import org.openspml.providers.one_c.api.connection.GlobalContext;

/**
 * Factory for generating 1C context.
 * 
 * @author <A href="mailto:abashev at gmail dot com">Alexey Abashev</A>
 * @version $Id$
 */
public class GlobalContextFactory {
	private final String connector;
	private final String url;
	
	public GlobalContextFactory() {
		ResourceBundle bundle = ResourceBundle.getBundle("application");
		
		this.connector = bundle.getString("connector");
		this.url = bundle.getString("url");
	}
	
	public GlobalContext getContext() {
		COMConnector con = new COMConnector(connector);

		return con.connect(url);
	}
	
	public void recycleContext(GlobalContext context) {
		// Nothing to do right now
		// In pooling here must be recycle methods
	}
}
